home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / xstrcat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  913 b   |  39 lines

  1. /*
  2. \funcref{xstrcat}{char $*$xstrcat (\params)}
  3.     {
  4.         {char} {*s1} {reallocatable string to cat to}
  5.         {char} {*s2} {string to cat to {\em s1}}
  6.     }
  7.     {reallocated string {\em s1} with {\em s2} concatenated to it}
  8.     {xrealloc()}
  9.     {xstrdup()}
  10.     {xstrcat.c}
  11.     {
  12.  
  13.         Function {\em xstrcat()} reallocates the string {\em s1} and then
  14.         concatenates {\em s2} to it. Therefore, the first argument of the
  15.         function must point to allocated memory. The second argument may be any
  16.         string, and can possibly be freed after the call.
  17.  
  18.     }
  19. */
  20.  
  21. #include "icrssdef.h"
  22.  
  23. char *xstrcat (s1, s2)
  24. char *s1, *s2;
  25. {
  26.     register unsigned
  27.         s1len;
  28.  
  29.     if (! s1 || ! *s1)
  30.         return (xstrdup (s2));
  31.     if (! s2 || ! *s2)
  32.         return (xstrdup (s1));
  33.  
  34.     s1len = strlen (s1);
  35.     s1 = xrealloc (s1, strlen (s1) + strlen (s2) + 1);
  36.     strcat (s1, s2);
  37.     return (s1);
  38. }
  39.